package goroutine

import (
	"fmt"
	"sync"
)

func Multiple() {
	var wg sync.WaitGroup
	//初始化计数器
	wg.Add(2)
	go func() {
		//注意defer修饰计数器
		defer wg.Done()
		for i := 0; i < 1000; i++ {
			fmt.Printf("Hello,Go! This is%d\n", i)
		}
	}()

	go func() {
		defer wg.Done()
		for i := 0; i < 1000; i++ {
			fmt.Printf("Hello,World! This is%d\n", i)
		}
	}()
	wg.Wait()
}
